package com.example.test.启动线程.可见性;

public class Kejianxing {

    private static  volatile boolean flag = false;
//    private static  boolean flag = false;

    public static void main(String[] args) throws InterruptedException {


        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                while (!flag){
                }
            }
        });

        thread.start();

        Thread.sleep(1000);

        flag = true;


    }
}
